Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g (10.1.3.5.0)

Part Number E13981-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

Configuring a Life Cycle Callback Method on a JPA Entity

You can specify a JPA entity class method as a callback method for any of the following life cycle events:

The entity class method must have the following signature:

int <METHOD>()

The entity class method can have any method name as long as it does not begin with ejb.

For more information, see the following:

Using Annotations

You can specify a JPA entity class method as a life cycle callback method using any of the following annotations:

  • @PrePersist

  • @PostPersist

  • @PreRemove

  • @PostRemove

  • @PreUpdate

  • @PostUpdate

  • @PostLoad

Example 7-30 shows how to use the @PrePersist annotation to specify JPA entity class method initialize as a life cycle callback method.

Example 7-30 @PrePersist

@Entity
@Table(name="EJB_PROJECT")
public class Project implements Serializable {
    ...
    @Id()
    @Column(name="PROJECT_ID", primaryKey=true)
    public Integer getId() {
         return id;
    }
 
    ...
 
    @PrePersist
    public int initialize() {
        ...
    }
}